package com.huawang.mdesign.model.service.constant;

import com.huawang.mdesign.model.service.facade.util.BatchQueryExecutor;
import com.huawang.core.definition.mof.UMLDefinitionConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author cdl
 */
@AllArgsConstructor
@Getter
public enum PropertyOperationEnum {

    OPERATIONAL_ACTIVITY("queryTaxonomyIsProvidedByOperationalActivity" + BatchQueryExecutor.QUERY_SUFFIX,
            UMLDefinitionConstants.UAF_MapsToCapability,
            UMLDefinitionConstants.UAF_OperationalActivity),
    RESOURCE_PERFORMER("queryTaxonomyIsExhibitedByResourcePerformer" + BatchQueryExecutor.QUERY_SUFFIX,
            UMLDefinitionConstants.UAF_Exhibits,
            UMLDefinitionConstants.UAF_ResourcePerformer),
    OPERATIONAL_PERFORMER("queryTaxonomyIsExhibitedByOperationalPerformer" + BatchQueryExecutor.QUERY_SUFFIX,
            UMLDefinitionConstants.UAF_Exhibits,
            UMLDefinitionConstants.UAF_OperationalAgent),
    CAPABILITIES("queryTaxonomyIsComposedOfCapabilities" + BatchQueryExecutor.QUERY_SUFFIX,
            UMLDefinitionConstants.UAF_CapabilityRole,
            UMLDefinitionConstants.TypedElement_type),
    ;

    private final String method;

    private final String type;

    private final String clientType;

    @Nullable
    public static PropertyOperationEnum getByMethod(String method) {
        return Arrays.stream(PropertyOperationEnum.values())
                .filter(e -> Objects.equals(e.getMethod(), method))
                .findFirst()
                .orElse(null);
    }
}
